<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Redis;

class ChangeBalance implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private $key;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($key)
    {
        //初始化数据
        $this->key = $key;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //队列处理逻辑 修改用户余额
        if(Redis::get($this->key)){
            $data=Redis::get($this->key);
            //获取到业务数据，执行业务处理 操作数据库等

            //Db::table("usercard")->.....
            //........

            //end
            echo "账号余额修改成功 ==》 业务数据日志：".json_encode($data,256);
        }



    }
}
